package leetcode_1001_1100;

import java.util.*;

public class LeeCode_1002 {
    public static void main(String[] args) {

    }
    private static List<String> commonChars(String[] words) {
        int[] tab = new int[26];
        Arrays.fill(tab, Integer.MAX_VALUE);
        for (String word : words) {
            int[] tmp = new int[26];
            for (int i = 0; i < word.length(); i++) {
                char c = word.charAt(i);
                tmp[c - 'a']++;
            }
            for (int i = 0; i < 26; i++) {
                tab[i] = Math.min(tab[i], tmp[i]);
            }
        }
        List<String> ans = new ArrayList<>();
        for (int i = 0; i < 26; i++) {
            if (tab[i] == Integer.MAX_VALUE)
                continue;
            for (int j = 0; j < tab[i]; j++) {
                ans.add((char)('a' + i) + "");
            }
        }
        return ans;
    }
}